<?php
$GLOBALS['Pd'] = "N";
require_once($_SERVER['DOCUMENT_ROOT']."/modules/timeclock/moduleconf.php");

	$Ids = $_GET['Pr'];
	
	$CO = count($Ids);
	
	for ($r = 0; $r < $CO; $r++) {
	
	if ($CO == 1) {
		$VAr = $Ids; 
		} else {
		$VAr = $Ids[$r];
		}

	$CDoc = "SELECT b.ref AS TypeID,
					b.name AS TypeName,
					DATE(a.EventTime) AS Date,
					Time(a.EventTime) AS Time,
					a.delaytime,
					a.RefType AS Type,
					d.name AS Status,
					n.name AS User,
					n.Cod,
					n.Secc,
					n.CatProf
					 FROM timeclock_delays AS a
				LEFT OUTER JOIN htck_delaytypes AS b ON b.ref = a.Justify
				INNER JOIN timeclock_operations AS c ON c.ref = a.RefOperation
				INNER JOIN htck_status AS d ON d.StatRef = a.Status AND Type = 2
				INNER JOIN main_users AS n ON n.ref = c.main_users_ref
				WHERE a.ref = {$VAr}";
	$Doc = $GLOBALS['CONN']->db_array($CDoc);
	for ($a = 1; $a <= $Doc[0]; $a++) { ?>

<table width="80%" align="center" cellpadding="30" cellspacing="0">
  <tr>
    <td colspan="6"><p><strong>Money Express<br>
        </strong><strong>AGêNCIA DE C&Acirc;MBIOS, LDA.<br>
      </strong><strong>Contribuinte nº 506 300 013 </strong></p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>&nbsp;</p>      <p align="center"><strong>FICHA DE AUSêNCIA</strong></p></td>
  </tr>
  <tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
</table>
<div align="center"></div>
<table width="95%" border="1" align="center" cellpadding="6" cellspacing="0">
  <tr>
    <td colspan="2">Nome: </td>
    <td colspan="4"><?php echo $Doc[$a]['User'];?></td>
  </tr>
  <tr>
    <td colspan="2">Cat. Profissional: </td>
    <td colspan="4"><?php echo $Doc[$a]['CatProf'];?></td>
  </tr>
  <tr>
    <td colspan="2">CÓdigo do Empregado: </td>
    <td colspan="4"><?php echo $Doc[$a]['Cod'];?></td>
  </tr>
  <tr>
    <td colspan="2">ServiÇo/ Secção: </td>
    <td colspan="4"><?php echo $Doc[$a]['Secc'];?></td>
  </tr>
  <tr>
    <td colspan="6" class="xl53"><strong>Período de Ausência    </strong></td>
  </tr>
  <tr>
    <td colspan="2">Deseja  </td>
    <td colspan="4" class="xl37"><?php //Faltar 
					echo 'Faltou'; ?></td>
  </tr>
  <tr>
    <td colspan="2"><span class="xl37">De <span class="xl44"><span class="xl47"><span class="xl29">
    </span></span></span></span></td>
    <td colspan="4"><span class="xl37"><span class="xl44"><span class="xl47"><span class="xl29">
      <?php echo $Doc[$a]['Date'];?></span></span></span></span> </td>
  </tr>
  <tr>
    <td colspan="2" class="xl46"><span class="xl30">às:<span class="xl47"><span class="xl29">
    </span></span></span></td>
    <td colspan="4" class="xl45"><span class="xl44"><span class="xl30"><span class="xl47"><span class="xl29">
      <span class="xl37">
      <?php echo $Doc[$a]['Time'];?>
      </span></span></span><span class="xl47"><span class="xl29">    </span></span></span></span> </td>
  </tr>
  <tr>
    <td colspan="2" class="xl30">N&uacute;mero de horas de ausência : </td>
    <td colspan="4" class="xl47"><span class="xl29">
      <?php echo date('H:i:s',$Doc[$a]['delaytime']-3600);?>
    </span></span>    </td>
  </tr>
  <tr>
    <td colspan="4"><strong>TIPO DE FALTA: </strong></td>
    <td><span class="xl29"><strong>
      <?php echo $Doc[$a]['TypeID'];?>
      <?php echo $Doc[$a]['TypeName'];?>
    </strong></span></td>
    <td></td>
  </tr>
  <tr>
    <td colspan="6"><p>&nbsp;</p>
      <p>&nbsp;</p>
      <p>Transmitido ao superior hierárquico em : <span class="xl29">
        <?php echo $Doc[$a]['Time'];?>
    </span></p>      </span></td>
  </tr>
  <tr>
    <td colspan="4"></td>
    <td>Assinatura: <br>
    ______________________________________________________</td>
    <td></td>
  </tr>
  <tr>
    <td colspan="4">DecisÃo do Superior Hierárquico: </td>
    <td><strong><span class="xl29">
      <?php echo $Doc[$a]['Status'];?>
    </span></span></strong></td>
    <td></td>
  </tr>
  <tr>
    <td colspan="6"><p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>Transmitido à direcção de Recursos Humanos em : ___/___/___ </p></td>
  </tr>
  <tr>
    <td colspan="4"></td>
    <td><p>Assinatura do Responsável pelo ServiÇo:<br>
    ______________________________________________________</p>    </td>
    <td></td>
  </tr>
  <tr>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
    <td></td>
  </tr>
</table>
<?php 
	} 
} ?>
<script charset="utf-8" type="text/javascript">window.print();</script>